home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 684 / cpuclr / cpuclr.asm < prev    next >
Assembly Source File  |  1995-03-18  |  2KB  |  150 lines

  1. ;
  2. ; cpuclr.asm
  3. ; ----------
  4. ;
  5. ; replaces BltClear() with a CPU based function for speed on 68030-systems
  6. ; compatible to V36's new "fill" feature 
  7. ;
  8. ; (C) 1991 Oliver Wagner
  9. ;
  10.  
  11. call    MACRO
  12.     xref    _LVO\1
  13.     jsr    _LVO\1(a6)
  14.     ENDM
  15.  
  16.  
  17.     section    "init",code
  18.  
  19.     xref    _LVOBltClear
  20.  
  21. ;
  22. ; entry function
  23. ;
  24.  
  25. entry:
  26.     move.l    4,a6
  27.     lea    gfxname(pc),a1
  28.     call    OldOpenLibrary
  29.     move.l    d0,a2
  30.     lea    dosname(pc),a1
  31.     call    OldOpenLibrary
  32.     move.l    d0,a3
  33.     move.l    d0,a6
  34.     call    Output
  35.     move.l    d0,d7
  36.     move.l    d0,d1
  37.     lea    head(pc),a0
  38.     move.l    a0,d2
  39.     moveq    #37,d3
  40.     call    Write
  41.  
  42.     move.l    _LVOBltClear+2(a2),a5
  43.     cmp.l    #'CPUC',-8(a5)
  44.     bne.s    install
  45.  
  46.     move.l    4,a6
  47.     move.l    -4(a5),d0
  48.     move.w    #_LVOBltClear,a0
  49.     move.l    a2,a1
  50.     call    SetFunction
  51.     lea    -12(a5),a0
  52.     move.l    a0,d1
  53.     ror.l    #2,d1
  54.     move.l    a3,a6
  55.     call    UnLoadSeg
  56.     lea    rem(pc),a0
  57.     bra.s    exit
  58.  
  59. install:
  60.     lea    entry-4(pc),a5
  61.     move.l    (a5),d0
  62.     addq.l    #3,d0
  63.     add.l    d0,d0
  64.     add.l    d0,d0
  65.     move.l    d0,a4    ; pointer to new func
  66.     clr.l    (a5)    ; kill segment pointer
  67.     move.l    a2,a1
  68.     move.w    #_LVOBltClear,a0
  69.     move.l    4,a6
  70.     call    SetFunction
  71.     move.l    d0,-4(a4)
  72.  
  73.     lea    ins(pc),a0
  74. exit:
  75.     move.l    d7,d1
  76.     move.l    a3,a6
  77.     move.l    a0,d2
  78.     moveq    #10,d3
  79.     call    Write
  80.     moveq    #0,d0
  81.     rts
  82.  
  83. gfxname:
  84.     dc.b    "graphics.library",0
  85. dosname:
  86.     dc.b    "dos.library",0
  87. head:
  88.     dc.b    $9b,"1mCPUCLR",$9b,"0m (C) 1991 Oliver Wagner: "
  89. ins:
  90.     dc.b    "installed",10
  91. rem:
  92.     dc.b    "removed  ",10
  93.  
  94.     section    "patch",data
  95.  
  96. id:    dc.l    'CPUC'
  97. oldfunc:
  98.     dc.l    '(-:]'
  99. ;
  100. ; this is the new bltclear() routine entry
  101. ;
  102. ; a0 = block
  103. ; d0 = size
  104. ; d1 = flags
  105.  
  106. newclear:
  107.     move.l    d2,a0
  108.     btst    #1,d1
  109.     beq.s    bytesize
  110. ; must calc size
  111.     move.l    d0,d2
  112.     and.l    #$ffff,d0
  113.     clr.w    d2
  114.     swap    d2
  115.     mulu    d2,d0
  116. bytesize:
  117.     moveq    #0,d2
  118.     btst    #2,d1
  119.     beq.s    dataok
  120.     move.l    d1,d2
  121.     swap    d2
  122. dataok:
  123.     btst    #1,d0
  124.     subq.l    #2,d0
  125. loop1:
  126.     move.w    d2,(a1,d0.l)
  127.     subq.l    #2,d0
  128.     bpl.s    loop1
  129.     move.l    a0,d2
  130.     rts
  131. ;
  132. ; more efficent clear
  133. ; if size%4 == 0
  134. ;
  135.  
  136. doloop2:
  137.     subq.l    #4,d0
  138.     move.w    d2,d1
  139.     swap    d2
  140.     move.w    d1,d2
  141.     swap    d2
  142. loop2:
  143.     move.l    d2,(a1,d0.l)
  144.     subq.l    #4,d0
  145.     bpl.s    loop2
  146.     move.l    a0,d2
  147.     rts
  148.  
  149.     END
  150.